home *** CD-ROM | disk | FTP | other *** search
- Path: osip22.ionet.net!user
- From: cpruett@ionet.net (Chris Pruett)
- Newsgroups: comp.lang.c
- Subject: Re: Pointer arithmetic
- Date: Sun, 10 Mar 1996 19:11:45 -0600
- Organization: Internet Oklahoma
- Message-ID: <cpruett-1003961911450001@osip22.ionet.net>
- References: <4h2r55$er@s3.iway.fr>
- NNTP-Posting-Host: osip22.ionet.net
- X-Newsreader: Yet Another NewsWatcher 2.1.1
-
- In article <4h2r55$er@s3.iway.fr>, Pascal Terracol <assetsto@pratique.fr> wrote:
-
- > Hello,
- >
- > this sample code have been correctly working on a pc 80286 processor
- >
- > I put it on a mac and the pointers seems to act differently...
- > any idea about that ?
- >
- >
- > int size, n1, n2 ;
- > Point *p_debut, *p1, *p2 ;
- /* "vecteur" de translation des adr */
- >
- > ....
- >
- > n1 = (int) (l->p1)/sizeof(Point) ;
- > n2 = (int) (l->p2)/sizeof(Point) ;
- >
- > p1 = p_debut + n1 ;
- > p2 = p_debut + n1 ;
- > ....
- >
-
- Could it be that the Mac's pointers are 32-bit and the '286 uses 16-bit
- pointers? When you cast the 286 pointer to (int) it works because
- the int is itself 16-bits. On the Mac the 32-bit pointer gets
- destroyed. Perhaps one could change the Mac's compiler setting to use
- 32-bit ints or cast using (long int) instead of (int).
-
- The compiler ought to complain with a warning when one tells it to cast a
- pointer to an inferior integer type.
-
- CP
-